package ronglei.day01.demo07String;

import java.awt.*;

/*
* public char[] tocharArray()  将当前字符串拆分成字符数组做为返回值
* public byte[] getBytes()获取当前字符串底层的字节数组
* public String replace(CharSequence oldString , CharSequence newString) 老字符替换成新字符 返回新字符
* 备注 CharSequence 接收字符串类型
*
*
*
* */
public class String05 {
    public static void main(String[] args) {
        //转换成字符数组
        char[] chars = "Hello".toCharArray();
        for (int i = 0; i < chars.length; i++) {
            System.out.println(chars[i]);
        }


        //转换成字节数组
        byte[] bytes = "abc".getBytes();
        System.out.println(bytes);
        for (int i = 0; i < bytes.length; i++) {
            System.out.println(bytes[i]);
        }

        //替换
        String str1 = "荣磊帅";
        String str2 = str1.replace("帅", "是的");
        System.out.println(str1);
        System.out.println(str2);

    }
}
